<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>专项工程--${fns:getConfig('productName')}</title>
<script type="text/javascript" src="${ctx}/scripts/appconfig.jsp" charset="utf-8" ></script>
<%@include file="/common/uihead.jsp" %>
<%@include file="/common/upload.jsp" %>
</head>
<body>
	<ul class="nav nav-tabs" style="margin: 0 4px; margin-bottom: 4px;">
		<li class="active">
			<a href="${ctx}/specialProject/listInfo.do?left=${fns:encodeParamUrl(left)}&top=${fns:encodeParamUrl(top)}&parentId=${fns:encodeParamUrl(parentId)}&LId=${fns:encodeParamUrl(LId)}">
				<i class="icon icon-list"></i>&nbsp;<span>专项工程列表</span>
			</a>
		</li>
<%-- 		<c:if test="${roleType eq 2 || roleType eq 3 }"> --%>
		<sec:authorize ifAnyGranted="ROLE_zxgc_add">
		<li>
			<a href="${ctx}/specialProject/input.do?left=${fns:encodeParamUrl(left)}&top=${fns:encodeParamUrl(top)}&parentId=${fns:encodeParamUrl(parentId)}&LId=${fns:encodeParamUrl(LId)}">
				<i class="icon icon-edit"></i>&nbsp;<span>新增专项工程</span>
			</a>
	 	</li>
	 	</sec:authorize>
<%-- 	 	</c:if> --%>
	</ul>
	<input type='hidden' name="" id="userRole" value="${roleType}">
	<form id="mainForm" class="form-horizontal" role="form" method="get" name="mainForm" style="">
		<div class="breadcrumb form-search" style="background-color: #f5f5f5;">
			<div>
				<label>关键字:</label> <input type="text" oninput="queryForGrid('mainForm','jqGrid')" onporpertychange="queryForGrid('mainForm','jqGrid')"
					name="filter_LIKES_projectName"
					value="${filter_LIKES_projectName}"
					placeholder="专项工程查询" />
			</div>
			
		</div>
		<table id="jqGrid"></table>
		<div id="jqGridPager"></div>
	</form>
	

<script type="text/javascript">
		var roleType = ${roleType};
		$(document).ready(function()
		{
			var jqgridH =  $(window).height()-380;
			var projectName = "${filter_LIKES_projectName}";
			postData = {filter_LIKES_projectName:projectName} //重新拼接请求数据
			$("#jqGrid").jqGrid(
			{ url : '${ctx}/specialProject/list.do',
			  mtype : "GET",
			  datatype : "json",
			  postData : postData,
			  page : 1,
			  viewrecords: true,
			  colModel:[
				{ label : "操作", name : "id", 
					  width : 180,   align : 'center', sortable : false, search : false ,
					  formatter: function (cellValue, options, rowObject){
							return formatterOpt(cellValue, rowObject['status']);
					  }
				},
				{
           	        label: '处理状态',
           	        name: 'status',
           	     	align:'center',
           	        width: 80,
           	    	 formatter:function(cellValue){
           	    		 if(cellValue == "1"){
           	    			 return "<span style='color:red'>"+Pengtu.buildCodeName(6009,cellValue)+"</span>";
           	    		 } else if(cellValue == "2"){
           	    			return "<span style='color:green'>"+Pengtu.buildCodeName(6009,cellValue)+"</span>";
           	    		 } else{
           	    			return Pengtu.buildCodeName(6009,cellValue);
           	    		 }
	                }
                },
				{
           	        label: '工程名称',
           	        name: 'projectName',
           	     	align:'center',
           	        width: 120,
           	        sortable : false
                },
                {
           	        label: '工程描述',
           	        name: 'projectDesc',
           	     	align:'center',
           	        width: 240,
           	     	sortable : false
                },{
           	        label: '截止时间',
           	        name: 'endTime',
           	     	align:'center',
           	        width: 120
                },
                {
           	        label: '提前预警时间',
           	        name: 'advanceTime',
           	     	align:'center',
           	        width: 100,
                },
//                 {
//            	        label: '预警频率',
//            	        name: 'frequency',
//            	     	align:'center',
//            	        width: 100,
//            	    	 formatter:function(cellValue){
// 	                 	return Pengtu.buildCodeName(6008,cellValue);
// 	                }
//                 },
                {
           	        label: '备份',
           	        name: 'remark',
           	     	align:'center',
           	        width: 240
                }
						],
			autowidth : false,width:$(window).width()-248,  height : jqgridH,scrollOffset:0, shrinkToFit : 400, rowNum : 10, viewrecords : true, rownumbers : true,
			jsonReader:{
    			root: "result",
    			page: "currentPage",
    			total: "totalPages",
    			records: "totalCount",
    			repeatitems: true,
    			cell: "cell",
    			id: "id",
    			userdata: "userdata",
    			subgrid: {root:"results", repeatitems: true, cell:"cell"}
    		},
    		prmNames: {
				page:"pageNo",
				rows:"pageSize",
				sort: "orderBy",
				order: "order",
				search:"_search",
				nd:"nd", id:"id",
				oper:"oper",
				editoper:"edit",
				addoper:"add",
				deloper:"del",
				subgridid:"id",
				npage: null,
				totalrows:"totalCounts"
			}, 
			rowList :[10,20,30], 
			pager : "#jqGridPager"
			});
		});
		function formatterOpt(id, status) {
			var editor = "<a href='${ctx}/specialProject/editor.do?left=${fns:encodeParam(left)}&top=${fns:encodeParam(top)}&LId=${fns:encodeParam(LId)}&id="+id+"' title='编辑'><i class='icon icon-edit' style='margin-top:4px;'></i>&nbsp;编辑</a>&nbsp;&nbsp;";
			var release = "<a href='javascript:void(0);'onclick='release(\"${ctx}/specialProject/release.do?left=${fns:encodeParam(left)}&top=${fns:encodeParam(top)}&LId=${fns:encodeParam(LId)}&id="+id+"\");' title='作废'><i class='icon-lock' style='margin-top:4px;'></i>&nbsp;作废</a>&nbsp;&nbsp;";
			var view = "<a href='${ctx}/specialProject/view.do?left=${fns:encodeParam(left)}&top=${fns:encodeParam(top)}&LId=${fns:encodeParam(LId)}&id="+id+"' title='查看'><i class='icon-eye' style='margin-top:3px;'></i>&nbsp;查看</a>"
			var close = "<a href='javascript:void(0);'onclick='closeProject(\"${ctx}/specialProject/close.do?left=${fns:encodeParam(left)}&top=${fns:encodeParam(top)}&LId=${fns:encodeParam(LId)}&id="+id+"\");' title='关闭'><i class='icon-close' style='margin-top:4px;'></i>&nbsp;关闭</a>&nbsp;&nbsp;";
			if(status == 0){ //正常状态
				//辖区局角色
				if(roleType ==1){
					<sec:authorize ifAnyGranted="ROLE_zxgc_delpro">
					return editor;
					</sec:authorize>
				} else if(roleType ==2||roleType==3){ //设置局和管理员角色
					<sec:authorize ifAnyGranted="ROLE_zxgc_delpro">
					return release+close+view;
					</sec:authorize>
				} else{ //其他角色
					return view;
				}
			} else if(status == 2){ //已关闭状态
				return view;
			} else { //已作废状态
				return view;
			}
			
			return view;
		}
		
		function  del(url){
			$.jBox.confirm("确认要删掉该项目吗？", '系统提示', function(v, h, f) {
				if (v == 'ok') {
					loading('正在提交，请稍等...');
					$.ajax({
						type : "POST",
						dataType : "json",
						url : url,
						success : function(data) {
							$.jBox.tip("删除成功", 'info');
							$("#jqGrid").trigger("reloadGrid");
							setTimeout("$.jBox.closeTip()", 1000);
						},
						error : function(data) {
						}
					});
				}
			}, {
				buttonsFocus : 1
			});
		};
		
		function  release(url){
			$.jBox.confirm("确认要作废该项目吗？<br/>作废之后，该项目将不能编辑", '系统提示', function(v, h, f) {
				if (v == 'ok') {
					loading('正在提交，请稍等...');
					$.ajax({
						type : "POST",
						dataType : "json",
						url : url,
						success : function(data) {
							$.jBox.tip("已作废", 'info');
							$("#jqGrid").trigger("reloadGrid");
							setTimeout("$.jBox.closeTip()", 1000);
						},
						error : function(data) {
						}
					});
				}
			}, {
				buttonsFocus : 1
			});
		};
		function  closeProject(url){
			$.jBox.confirm("确认要关闭该项目吗？<br/>关闭之后，将不能上传专项数据", '系统提示', function(v, h, f) {
				if (v == 'ok') {
					loading('正在提交，请稍等...');
					$.ajax({
						type : "POST",
						dataType : "json",
						url : url,
						success : function(data) {
							$.jBox.tip("关闭", 'info');
							$("#jqGrid").trigger("reloadGrid");
							setTimeout("$.jBox.closeTip()", 1000);
						},
						error : function(data) {
						}
					});
				}
			}, {
				buttonsFocus : 1
			});
		};
</script>
</body>
</html>